
export default {
  filters: {
    Null: (value) => {
      return value ? value : '-'
    },
    formatData: (value, fmt) => {
      if (!value) { return '' }
      let getDate = new Date(value)
      let o = {
        'M+': getDate.getMonth() + 1,
        'd+': getDate.getDate(),
        'h+': getDate.getHours(),
        'm+': getDate.getMinutes(),
        's+': getDate.getSeconds(),
        'q+': Math.floor((getDate.getMonth() + 3) / 3),
        'S': getDate.getMilliseconds()
      }
      if (/(y+)/.test(fmt)) {
        fmt = fmt.replace(RegExp.$1, (getDate.getFullYear() + '').substr(4 - RegExp.$1.length))
      }
      for (let k in o) {
        if (new RegExp('(' + k + ')').test(fmt)) {
          fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
        }
      }
      return fmt
    },
    Money: (value) => {
      if (!value) return '0.00'
      let valueAfter = parseFloat(value / 100).toFixed(2)
      return valueAfter
    },
    ApplyCity: (obj) => {
      let String = ''
      if (obj) {
        let Province = obj[0] ? obj[0].name : ''
        let City = obj[1] ? obj[1].name : ''
        let Area = obj[2] ? obj[2].name : ''
        String = Province + ' ' + City + ' ' + Area
      } else {
        String = '请选择城市'
      }
      return String
    },
    getValueByArray: (ids, arr) => {
      if (!ids) { return }
      const idsArray = String(ids).split(',').map(item => {
        return arr.filter(val => val.id == item)[0]
      })
      const idsArrayTitle = idsArray.map(item => {
        return item.title
      }).join(' ')
      return idsArrayTitle
    },

    mobile: (mobile) => {
      let key = String(mobile)
      if (key.length < 11) { return '-' }
      var str = key.substr(0, 3) + "****" + key.substr(7);
      return str
    },

    timerdeadline: (t) => {
      t = -t
      if (!t || t < 0) return "00:00:00";
      if (t < 60) return "00:00:" + ((i = t) < 10 ? "0" + i : i);
      if (t < 3600) return "00:" + ((a = parseInt(t / 60)) < 10 ? "0" + a : a) + ":" + ((i = t % 60) < 10 ? "0" + i : i);
      if (3600 <= t) {
        var a, i, e = parseInt(t / 3600);
        return (e < 10 ? "0" + e : e) + ":" + ((a = parseInt(t % 3600 / 60)) < 10 ? "0" + a : a) + ":" + ((i = t % 60) < 10 ? "0" + i : i);
      }
    },
    orderStateid: (val) => {
      switch (Number(val)) {
        case 1:
          return '待付款';
        case 2:
          return '已付款';
        case 3:
          return '已退单';
        default:
          break;
      }
    },

    stateId: (val) => {
      switch (Number(val)) {
        case 1:
          return '已预约';
        case 2:
          return '上课中';
        case 3:
          return '已完成';
        case 4:
          return '课程取消';
        case 5:
          return '课程取消';
        case 6:
          return '课程取消';
        case 7:
          return '课程取消';
        default:
          break;
      }
    },

    taskState: (val) => {
      switch (Number(val)) {
        case 0:
          return '待布置';
        case 1:
          return '已布置';
        case 2:
          return '待批改';
        case 3:
          return '已批改';
        default:
          break;
      }
    },
    taskTeacherState: (val) => {
      switch (Number(val)) {
        case 0:
          return '待布置';
        case 1:
          return '待批改';
        case 2:
          return '已批改';
        default:
          break;
      }
    },
    userStatus: (val) => {
      switch (String(val)) {
        case '1':
          return '添加未审核';
        case '2':
          return '认证完成机构';
        case '3':
          return '关闭机构';
        default:
          break;
      }
    },
    EnableStatus: (val) => {
      switch (String(val)) {
        case '0':
          return 'EnableStatus-0';
        case '1':
          return 'EnableStatus-1';
        default:
          break;
      }
    },
    taskStatus: (val) => {
      switch (String(val)) {
        case '0':
          return 'taskStatus-0';
        case '1':
          return 'taskStatus-1';
        default:
          break;
      }
    },
    proxyStatus: (val) => {
      switch (String(val)) {
        case '0':
          return 'proxyStatus-0';
        case '1':
          return 'proxyStatus-1';
        default:
          break;
      }
    },
    typeStatus: (val) => {
      switch (String(val)) {
        case '0':
          return '全部';
        case '1':
          return '工作类型';
        case '2':
          return '工厂规模';
        case '3':
          return '食住情况';
        case '4':
          return '时间配置';
        default:
          break;
      }
    },
  }
}